/* AI聊天界面主样式 */
.ai-chat-container {
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  display: flex;
  flex-direction: column;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #ffffff;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  z-index: 10;
  height: 48px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  color: #374151;
  transition: all 0.2s;
  font-size: 16px;
}

.header-button:hover {
  background-color: #f3f4f6;
  border-color: #d1d5db;
}

.header-button:active {
  background-color: #e5e7eb;
}

.header-button.history {
  font-size: 18px;
}

.header-button.new-chat {
  font-size: 16px;
}

.chat-body {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

.conversation-panel {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background-color: #ffffff;
  border-right: 1px solid #e5e7eb;
  z-index: 5;
  animation: slideIn 0.3s ease;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  margin-left: 0;
  transition: margin-left 0.3s ease;
}

.chat-messages.with-panel {
  margin-left: 280px;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* 头部导航栏 */
.chat-header {
  height: 64px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

/* 头部左侧区域 */
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  min-width: 0; /* 允许flex子项收缩 */
}

/* 头部右侧区域 */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0; /* 允许flex子项收缩 */
}

/* AI模型选择器样式 */
.model-selector-container {
  position: relative;
  flex-shrink: 0;
  z-index: 1001; /* 确保下拉菜单在最上层 */
}

.model-selector-button {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 18px;
  cursor: pointer;
  color: white;
  font-weight: 600;
  min-width: 110px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  font-size: 13px;
  height: 36px;
  border: none;
  outline: none;
}

.model-selector-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.model-selector-button .model-avatar {
  margin-right: 6px;
  font-size: 15px;
}

.model-selector-button .model-name {
  flex: 1;
  text-align: center;
}

.model-selector-button .dropdown-arrow {
  margin-left: 6px;
  transition: transform 0.2s ease;
}

.model-selector-button .dropdown-arrow.open {
  transform: rotate(180deg);
}

/* 模型选择下拉菜单 */
.model-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: white;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  margin-top: 12px;
  z-index: 1002; /* 确保在最上层 */
  overflow: hidden;
  border: 1px solid #f0f0f0;
  width: 180px;
}

.model-option-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f8f9fa;
  transition: background-color 0.2s ease;
}

.model-option-item:last-child {
  border-bottom: none;
}

.model-option-item:hover {
  background-color: #f8f9fa;
}

.model-option-item .option-avatar {
  margin-right: 10px;
  font-size: 16px;
}

.model-option-item .option-info {
  flex: 1;
}

.model-option-item .option-name {
  font-weight: 600;
  color: #212529;
  font-size: 13px;
}

.model-option-item .option-description {
  font-size: 11px;
  color: #6c757d;
  margin-top: 2px;
}

/* 头部按钮样式 */
.header-button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  border: 1px solid;
  flex-shrink: 0;
}

.header-button:hover {
  transform: scale(1.05);
}

/* 新建对话按钮 */
.header-button.new-chat {
  background-color: #e3f2fd;
  border-color: #2196f3;
}

.header-button.new-chat:hover {
  background-color: #bbdefb;
}

/* 对话历史按钮 */
.header-button.history {
  background-color: #f3e5f5;
  border-color: #9c27b0;
}

.header-button.history:hover {
  background-color: #e1bee7;
}

/* 清空聊天按钮 */
.header-button.clear {
  background-color: #f8f9fa;
  border-color: #6c757d;
}

.header-button.clear:hover {
  background-color: #e9ecef;
}

/* 服务状态按钮 */
.header-button.status {
  background-color: #e8f5e8;
  border-color: #28a745;
}

.header-button.status:hover {
  background-color: #d4edda;
}

/* 重置滚动按钮 */
.header-button.reset-scroll {
  background-color: #fff3e0;
  border-color: #ff9800;
}

.header-button.reset-scroll:hover {
  background-color: #ffe0b2;
}

/* 深度思考选择器容器 */
.deep-thinking-selector {
  position: relative;
  display: inline-block;
  margin: 0 4px;
}

/* 思考模式选择器 */
.deep-thinking-select {
  appearance: none;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 14px;
  line-height: 20px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 90px;
  height: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}

.deep-thinking-select:hover {
  border-color: #d1d5db;
  background-color: #f9fafb;
}

.deep-thinking-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.deep-thinking-select option {
  background-color: white;
  color: #374151;
  padding: 8px;
}

/* 模型选择器样式 */
.model-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 4px;
}

.model-button {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 20px;
  color: #374151;
  transition: all 0.2s;
  height: 32px;
  gap: 6px;
}

.model-button:hover {
  border-color: #d1d5db;
  background-color: #f9fafb;
}

.model-button .model-icon {
  font-size: 16px;
}

.model-button .model-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 聊天消息容器 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* 消息样式 */
.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  position: relative;
  animation: messageSlideIn 0.3s ease-out;
  word-wrap: break-word;
  line-height: 1.5;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.message.ai {
  align-self: flex-start;
  background: white;
  color: #1e293b;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* 深度思考模式特殊样式 */
.message.ai.deep-thinking {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-left: 4px solid #8b5cf6;
  position: relative;
}

.message.ai.deep-thinking::before {
  content: '🧠';
  position: absolute;
  top: -8px;
  left: -8px;
  background: #8b5cf6;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

/* 消息时间戳 */
.message-timestamp {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: center;
}

/* 消息内容 */
.message-content {
  margin: 0;
  white-space: pre-wrap;
  position: relative;
  padding-right: 40px;
}

.tts-button {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
  transition: opacity 0.3s;
}

.tts-button:hover {
  opacity: 1;
}

/* 加载状态 */
.message.loading {
  opacity: 0.7;
}

.message.isStreaming {
  animation: typing 1s infinite;
}

/* 输入区域 */
.chat-input-area {
  padding: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.input-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border-radius: 24px;
  padding: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 16px;
  font-size: 14px;
  background: transparent;
  resize: none;
  min-height: 20px;
  max-height: 120px;
  line-height: 1.5;
}

.chat-input::placeholder {
  color: #94a3b8;
}

/* 发送按钮 */
.send-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.send-button:active {
  transform: translateY(0);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 附件按钮 */
.attachment-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.attachment-button:hover {
  background: #e2e8f0;
  color: #475569;
}

/* 思考模式指示器 */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 16px;
  font-size: 12px;
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.thinking-indicator.auto {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.2);
}

.thinking-indicator.off {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.2);
}

/* 动画效果 */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typing {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .chat-header {
    padding: 0 8px;
    height: 56px;
  }

  .header-left {
    gap: 8px;
  }

  .header-right {
    gap: 4px;
  }

  .model-selector-button {
    min-width: 90px;
    font-size: 12px;
    padding: 4px 10px;
  }

  .header-button {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 480px) {
  .chat-header {
    padding: 0 4px;
  }

  .model-selector-button {
    min-width: 80px;
    font-size: 11px;
    padding: 3px 8px;
  }

  .header-button {
    width: 24px;
    height: 24px;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  .ai-chat-container {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  }

  .chat-header {
    background: rgba(30, 41, 59, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  .message.ai {
    background: #334155;
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .message.ai.deep-thinking {
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
  }

  .chat-input-area {
    background: rgba(30, 41, 59, 0.95);
    border-top-color: rgba(255, 255, 255, 0.1);
  }

  .input-container {
    background: #334155;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .chat-input {
    color: #f1f5f9;
  }

  .chat-input::placeholder {
    color: #64748b;
  }

  .model-button {
    background: #334155;
    border-color: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
  }

  .model-dropdown {
    background: #334155;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .model-option {
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  .model-option:hover {
    background: #475569;
  }

  .model-option.active {
    background: #1e40af;
  }
}

.speak-button {
  margin-left: 10px;
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  background-color: #1890ff;
  color: white;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s;
}

.speak-button:hover {
  background-color: #40a9ff;
}

.speak-button:disabled {
  background-color: #d9d9d9;
  cursor: not-allowed;
}

.speak-button.speaking {
  background-color: #52c41a;
}
